package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IPublicationPictureBeforeView;
import com.cloudsigns.factorymanager2.engineering.IView.IPublicationQuestionFeedBackView;
import com.cloudsigns.factorymanager2.engineering.model.IPublicationPictureBeforeModel;
import com.cloudsigns.factorymanager2.engineering.model.IPublicationQuestionFeedBackModel;
import com.cloudsigns.factorymanager2.engineering.model.PublicationPictureBeforeModel;
import com.cloudsigns.factorymanager2.engineering.model.PublicationQuestionFeedBackModel;

/**
 * Created by tony on 2018/5/30.
 */

public class PublicationQuestionFeedBackPresenter {
    private IPublicationQuestionFeedBackView view;
    private IPublicationQuestionFeedBackModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public PublicationQuestionFeedBackPresenter(IPublicationQuestionFeedBackView view) {
        this.view = view;
        this.model = new PublicationQuestionFeedBackModel();
    }

    public void publicationQuestionFeedBack() {

        model.publicationQuestionFeedBack(view.getEngineeringPublicationMediaId(), view.getOrderId(), view.getFeedbackPicList(), view.getUnusualReason(), new PublicationQuestionFeedBackModel.OnPublicationQuestionFeedBackListener() {
            @Override
            public void publicationQuestionFeedBackSuccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.publicationQuestionFeedBackSuccess();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void publicationQuestionFeedBackFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.publicationQuestionFeedBackFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
